import React, { useEffect, useState } from 'react'
import { Switch, Form } from 'antd'
import EventHub from '../EventHub/index.jsx'
const { Item: FormItem } = Form

export function ESwitch({ params }) {
  const { formType, value, label, index, children, onChange, ...other } = params || {}
  const [ESwitchValue, setESwitchValue] = useState(value)
  const FormItemParams = {
    label: label === null ? '' : (label ? label : ' '),
    colon: !!label
  }


  useEffect(() => {
    console.log(params, index, "--------   ESwitch ---------------");
  }, [params.value])

  return <FormItem {...FormItemParams}>
    <Switch
      checked={ESwitchValue}
      onChange={
        (value) => {
          setESwitchValue(value)  // true 或者false
        }}
    />
  </FormItem>

}